package scheduledtasks.parscorn;



import scheduledtasks.entity.TaskObj;
import java.util.Date;
/**
 * 【小时解析功能]
 *
 * @author tiny
 * @version 1.0
 * @company bc
 * @copyright (c) 2022 bcInc. All rights reserved.
 * @date 2022-11-08 16:00:26
 * @since
 */
public class HoursParse extends ParseAbstract {
    @Override
    public boolean pars(String cron, TaskObj obj) {
        String cronstr=ParsUntil.getcron(cron,2);
        /*执行时间*/
        Date date=new Date(obj.getTime());
        /*现在*/
        Date dateNow=new Date(System.currentTimeMillis());
        if(cronstr.equals("*") ){
            return   getParseAbstract().pars(cron,obj);
        }
        if(cronstr.split("/").length==1){
            if(Integer.valueOf(cronstr)==dateNow.getHours()){
                return  getParseAbstract().pars(cron,obj);
            }
        }else {
            if(System.currentTimeMillis()-obj.getTime()>=Integer.valueOf(cronstr.split("/")[1])*1000*60*60){
                return getParseAbstract().pars(cron, obj);
            }
        }
        return false;
    }
}
